package com.sx.export.config;

import org.apache.tomcat.util.threads.TaskThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolExcuterConfig {

    @Bean
    public ThreadPoolExecutor getThreadPoolExcuter() {
        ThreadFactory namedThreadFactory = new TaskThreadFactory("exportExcel-",false,Thread.NORM_PRIORITY);
        return new ThreadPoolExecutor(10,20,60,
                TimeUnit.SECONDS,new LinkedBlockingQueue<>(100), namedThreadFactory ,new ThreadPoolExecutor.DiscardOldestPolicy());
    }
}
